﻿#include "precomp.h"
#include "jchartprivate.h"

JCartesianChart::JCartesianChart(QGraphicsItem *parent, Qt::WindowFlags wFlags) :
    QChart(parent, wFlags)
{
    init();
}

JCartesianChart::JCartesianChart(ChartType type, QGraphicsItem *parent, Qt::WindowFlags wFlags) :
    QChart(type, parent, wFlags)
{
    init();
}

void JCartesianChart::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
    QChart::mouseDoubleClickEvent(event);

    //
    Q_EMIT doubleClicked(true);
}

void JCartesianChart::init()
{
    //
    // Seems that QGraphicsView (QChartView) does not grab gestures.
    // They can only be grabbed here in the QGraphicsWidget (QChart).
    grabGesture(Qt::PanGesture);
    grabGesture(Qt::PinchGesture);
    setAnimationOptions(QChart::SeriesAnimations);
    //legend()->hide();
    setMargins(QMargins(3, 3, 3, 3));
    layout()->setContentsMargins(0, 0, 0, 0);
}
